﻿@using System.Web.Mvc.Html
@using Newtouch.Infrastructure
@{
    ViewBag.Title = "就诊记录选择";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    .table-responsive {
        border: 0;
    }

    .ui-jqgrid .ui-jqgrid-pager .ui-pager-table {
        width: 90%;
    }
</style>
<div class="topPanel">
    <table class="form">
        <tr>
            <th class="formTitle" style="width:50px;">卡号：</th>
            <td class="formValue" style="width: 80px;">
                <input id="txt_kh" name="txt_blh" type="text" class="form-control newtouch_Readonly" placeholder="卡号" />
            </td>
            <th class="formTitle" style="width:55px;">卡类型：</th>
            <td class="formValue" style="width: 100px;">
                @Html.DropDownList("selCardType", EnumCardType.XNHJYK.ToDescSelectList(), "全部", new { @class = "form-control" })
            </td>
            <th class="formTitle" style="width:75px;">挂号时间：</th>
            <td class="formValue">
                <input id="gh_kssj" type="text" class="form-control input-wdatepicker formClearIgnore" style="width: 88px; float:left;" value="@DateTime.Now.ToString("yyyy-MM-01")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                <span style="margin-left:2px; float: left; line-height: 25px;">—</span>
                <input id="gh_jssj" type="text" class="form-control input-wdatepicker formClearIgnore" style="width: 88px;float:left;margin-left:2%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
            </td>
            <td class="formTitle" style="width: 50px;">
                <button type="button" id="btn_search" class="btn btn-primary btn-md">查询</button>
            </td>
        </tr>
    </table>
</div>
<div class="gridPanel">
    <table id="opalGridList"></table>
</div>
<script>
    var $gridList = $("#opalGridList");
    var kh = $.request("kh");
    var cardType = $.request("cardType");
    var zjh = $.request("zjh");
    $(function () {
        $("#txt_kh").val(kh);
        $("#selCardType").val(cardType);
        gridList();
        $("#btn_search").click(function () {
            if ($("#gh_kssj").val() === "") $("#gh_kssj").val("@DateTime.Now.ToString("yyyy-MM-01")");
            if ($("#gh_jssj").val() === "") $("#gh_kssj").val("@DateTime.Now.ToString("yyyy-MM-dd")");
            $gridList.jqGrid("clearGridData");
            $gridList.jqGrid('setGridParam', {
                postData: param(),
                url: "/OutpatientManage/OutpatCharge/GetpatientAccountList"
            }).trigger('reloadGrid');
        });
    });

    //初始化
    function gridList() {
        $gridList.dataGrid({
            height: $(window).height() - 130,
            postData: param(),
            url: "/OutpatientManage/OutpatCharge/GetpatientAccountList",
            colModel: [
                { label: '病历号', name: 'blh', width: 100, align: 'left' },
                { label: '门诊号', name: 'mzh', width: 100, align: 'left' },
                { label: '卡类型', name: 'CardTypeName', hidden: true },
                { label: '姓名', name: 'xm', width: 100, align: 'left' },
                { label: '病人性质名称', name: 'brxzmc', width: 100, align: 'left' },
                { label: '挂号日期', name: 'ghrq', width: 100, align: 'left' },
                { label: 'xb', name: 'xb', hidden: true },
                { label: 'brxz', name: 'brxz', hidden: true },
                { label: 'csny', name: 'csny', hidden: true }
            ],
            viewrecords: true,
            ondblClickRow: function (rowid, iRow, iCol, e) {
                PatDbGrid(rowid);
            }
        });
    }

    function param() {
        return { kssj: $("#gh_kssj").val(), jssj: $("#gh_jssj").val(), kh: kh,zjh:zjh, cardType: cardType};
    }

    function PatDbGrid(rowId) {
        var rowData = $gridList.jqGrid('getRowData', rowId);
        var obj = new Object();
        obj.blh = rowData.blh;
        obj.mzh = rowData.mzh;
        obj.xm = rowData.xm;
        obj.xb = rowData.xb;
        obj.csny = rowData.csny;
        obj.brxzmc = rowData.brxzmc;
        obj.brxz = rowData.brxz;
        obj.CardTypeName = rowData.CardTypeName;
        $.currentWindow().chooseOneMzjl(obj);
        $.modalClose();
    }
</script>